package ophiux.wechat.template.util.parse.json;

import ophiux.OphiuxWechatTemplateMessageException;
import ophiux.wechat.template.util.parse.IConvert;
import ophiux.wechat.template.util.parse.IOphiuxApiParser;

public class OphiuxApiJsonParser<T> implements IOphiuxApiParser<T> {

	//内部转换器
	private IConvert jsonConvert = new JsonConverter();
	//目标类
	private Class<T> clzz; 
	
	public OphiuxApiJsonParser(Class _clzz){
		this.clzz = _clzz;
	}
	
	@Override
	public T parser(String dataSource) throws OphiuxWechatTemplateMessageException {
		return jsonConvert.toEntity(clzz, dataSource);
	}

}
